import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:getx_simple_code/pages/diovc/pojo/dishesEntity.dart';

import 'logic.dart';

class DiovcPage extends GetView<DiovcLogic> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text('Dio'),
        ),
        body: GetBuilder<DiovcLogic>(
          builder: (logic) {
            return _buildListView(controller.state.entity.data?.records);
          },
        ));
  }

  _buildListView(List<Records>? items) {
    return items == null
        ? Center(
            child: Column(
              children: [
                Text("暂无数据"),
              ],
            ),
          )
        : ListView.separated(
            itemCount: items.length,
            itemBuilder: (context, index) {
              final Records item = items[index];
              return ListTile(
                title: Text('菜品名称:${item.name}',style: TextStyle(fontSize: 20,color: Colors.black),),
                trailing: Text("分类:${item.categoryName}",style: TextStyle(fontSize: 18,color: Colors.orange),),
                onTap: () => {
                  controller.jumpdetail(item),
                },
              );
            },
            separatorBuilder: (BuildContext context, int index) {
              return Divider();
            },
          );
  }
}
